<?php
session_start();
header("Content-type: text/html; charset=utf-8"); 
//载入ecd类
require_once('lib/Ecd.class.php');


const url = "http://www.etuocloud.com/gateway.action";
const app_key = 'KP3e3CxLk2eldCTDFM0KP3QDLVq3B9Wl';
const app_secret = 'wKhjBD1VtZkG4XWlVPIHW733u7kTPsfPCdQ3iwMuqaRCorqhlbV2KlN75mRvNUY1';
const format = 'xml';

//初始化
$ecd = new Ecd(url,app_key,app_secret,format);

function random($length = 6 , $numeric = 0) {
	PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
	if($numeric) {
		$hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
	} else {
		$hash = '';
		$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghjkmnpqrstuvwxyz';
		$max = strlen($chars) - 1;
		for($i = 0; $i < $length; $i++) {
			$hash .= $chars[mt_rand(0, $max)];
		}
	}
	return $hash;
}
$_SESSION['send_code'] = random(4,1);
	
//发送验证码短信
$ecd->send_sms_code($_POST['mobile'],'1',$_SESSION['send_code'],'');

